package lab02.test11;

public class Rectangle implements Printx {
    double width;
    double height;

    //构造长方形的方法
    public Rectangle() {

    }

    //构造有参的长方形方法
    public Rectangle(double width, double height) {
        this.height = height;
        this.width = width;
    }

  public void setWidth(double width) {
        this.width = width;
    }

    public double getWidth() {
        return width;
    }

    public void setHeight(double height) {
        this.height = height;
    }

    public double getHeight() {
        return height;
    }


    //构造面积的方法
    public double getArea() {
        double area;
        return area=height*width;
    }
//构造周长的方法
    public  double getPerimeter(){
        double perimeter;
        return perimeter=(height+width)*2;
    }


//重写父类的printMyWay方法
    @Override
    public void printMyWay() {
       System.out.println("边长："+width +"  "+height+" "+"面积："+getArea()+" "+"周长："+getPerimeter());
    }
}

